
function ListNode(val, next) {
  this.val = (val===undefined ? 0 : val)
  this.next = (next===undefined ? null : next)
}

var deleteDuplicates = function(head) {
  let dummy = new ListNode()
  dummy.next = head
  let cur = dummy
  while (cur && cur.next) {
    if (cur.next.val === cur.next.next.val) {
      let value = cur.next.val
      while (cur.next.val === value) {
        cur.next = cur.next.next
      }
    } else {
      cur = cur.next
    }
  }
  return dummy.next
};